<?php
    $this->headTitle($this->layout()->title . ' - ' . $this->topic->title);
    if ($this->robots) {
        $this->headMeta()->appendName('robots', 'index, follow');
    } else {
        $this->headMeta()->appendName('robots', 'noindex, follow');
    }
    $this->headScript()->prependFile('/scripts/topicScript.js',
                                     'text/javascript', array());
?>
<div id="sidebar">
    <div class="title">Категории:</div>
    <?php echo $this->listCategory(); ?>
    <div class="title">Теги:</div>
    <?php echo $this->listTags() ?>
    <div class="title">Статистика:</div>
    <?php include_once 'statistic.phtml'; ?>
</div>
<div id="strlist" class="left">
<div class="strecord">
    <div class="theme">
        <?php
            if ($this->topic->hide) {
                echo 'Hidden: ';
            }
            echo $this->topic->title . PHP_EOL; ?>
    </div>
    <div class="dateline">
        Автор: <a href="<?php echo $this->url(array('id' => $this->topic->user_id),'author');
                         ?>" class="author"><?php echo $this->nameUser[$this->topic->user_id]; ?></a><br/>
        <?php echo $this->dateTimeFormat($this->topic->time_created); ?>
    </div>
    <div class="topic-text">
        <?php echo $this->topicPreview($this->topic['text_post'], 0, FALSE); ?>
    </div>
    <p>Категория: <a href="<?php echo $this->url(array('id' => $this->topic->category_id),
                                                'category') ?>">
    <?php echo $this->nameCategory[$this->topic->category_id]['name']; ?></a></p>
    <p><?php $tag = $this->viewTags($this->topic->post_id);
              if ($tag) echo $tag; ?></p>
    <div class="comments_link"><div style="float: left; text-align: left;">Просмотров: <?php
        echo $this->counts['views']; ?></div><?php
        echo $this->numberOfComments($this->counts['comments']); ?> | <a href="<?php
        echo $this->url(array('id' => $this->topic->post_id,
                              'hide' => 'reply'), 'topic') . '/#comment_add';
        ?>">Оставить комментарий</a></div>
</div>
</div>
<div id="comment_box">
    <?php echo $this->paginationControl($this->comments, 'Elastic', 'main_paginator.phtml'); ?>
    <div id="commentList">
    <?php if (count($this->comments)) { ?>
    <?php   foreach ($this->comments as $comment) { ?>
        <div class="comment_item">
        <div class="comment_title"><?php
            if (!empty($comment->user_id)) { ?>
                <a href="<?php echo $this->url(array('id' => $comment->user_id),'author'); ?>"><?php
                        echo $this->nameUser[$comment->user_id]; ?></a>
            <?php } else {
                if (empty($comment->website)) {
                    echo '<b>' . $comment->name . '</b>';
                } else {
                    echo '<a class="notregistered" href="' . $comment->website . '">' . $comment->name . '</a>';
                }
            }
            echo ' : ';
            if ($this->showIpAddres) {
                echo $comment->ip_addr;
            } ?>
            <div class="comment_datetime"><?php echo $this->dateTimeFormat($comment->time_created); ?></div>
        </div>
            <div class="comment_text">
            <?php echo $comment->text; ?>
            </div>
        </div>
    <?php   } ?>
    <?php } ?>
    </div>
    <?php echo $this->paginationControl($this->comments, 'Elastic', 'main_paginator.phtml'); ?>
    <div id="toggle_comment_add">
    Добавить свой комментарий:
    </div>
    <div id="comment_add">
        <?php echo $this->form; ?>
        <div class="form_note">
        Поля, помеченные <img src="/img/req_asterisk.png" alt="asterisk" class="no-style" />, обязательны для заполнения.<br />
        Адрес электронной почты нигде не отображается, необходим только для обратной связи.<br/>
        Веб-сайт вводите в формате http://example.org, при желании, конечно.
        </div>
    </div>
</div>
<script type="text/javascript">
var formHide = <?php if ($this->formHide) echo '1'; else echo '0'; ?>;
var linkCommentBlock = '<?php echo $this->url(array('id' => $this->topic->post_id), 'topic'); ?> #captcha-element > *';
</script>
